package com.company.cloud.uba.modules.bus.consumer;


import com.alibaba.fastjson.JSON;
import com.company.cloud.common.bean.AnonyTokenModel;
import com.company.cloud.common.constant.ConfigConstants;
import com.company.cloud.common.mq.redis.client.consumer.MQSaasResult;
import com.company.cloud.uba.modules.app.service.UserIdMappingService;
import com.company.common.server.config.mq.constant.MQTopicKeys;
import com.company.common.server.config.mq.models.MQUserBrowseLogModel;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

@Log4j2
@ConditionalOnProperty(value = ConfigConstants.CONFIG_Active_MQ_ENABLED, havingValue = "true")
@Service
public class UserIdMapActiveConsumer {


    @Autowired
    private UserIdMappingService userIdMappingService;

    @JmsListener(destination = MQTopicKeys.MQ_AnonyToken_Topic ,containerFactory = "queueListener")
    public void consume(String message){
        try {
            AnonyTokenModel anonyTokenModel= JSON.parseObject(message,AnonyTokenModel.class);
            userIdMappingService.addUserIdMapping(anonyTokenModel);
        }catch (Exception e){
            log.debug("+++++用户匿名标识消费者,执行业务错误:",e.getCause());
        }
    }
}
